package com.tbs.parkingsaleapp.UI.Listenners;

import abstergo.tbs.betterasyc.AsycBase.AsycWorker;
import android.view.View;
import android.widget.Toast;
import com.tbs.parkingsaleapp.Http.JsonData.ParkResult;
import com.tbs.parkingsaleapp.Http.Listenner.PutOrderHttper;
import com.tbs.parkingsaleapp.SystemManager.SystemDataMananger;

public class BuyClickListenner implements View.OnClickListener {
    @Override
    public void onClick(View v) {
        ParkResult park= (ParkResult) v.getTag();
        if(SystemDataMananger.Buyable(park))
        {
            PutOrderHttper httper=new PutOrderHttper(v);
            AsycWorker<Object,Integer> http=new AsycWorker<>(1);
            http.setResultAction(httper);
            http.setBackgroundAction(httper).setContext(v.getContext());
            http.Run(SystemDataMananger.getLogined().getUserinfo().getId(),park.getPark().getLocation(),park.getPark().getId());
            v.setEnabled(false);
        }
        else
        {
            Toast.makeText(v.getContext(),"不可购买",Toast.LENGTH_SHORT).show();
        }
    }
}
